package com.itheima.edu.info.a;

public class c {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        int a = 10;
        int min = 0;
        int max = arr.length - 1;
        while (min <= max) {
            int mid = (max + min) / 2;
            if (arr[mid] < a) {
                min = mid + 1;
            } else if (arr[mid] > a) {
                max = mid - 1;
            } else {
                System.out.println(mid);
                return;
            }
        }
        System.out.println(-1);
    }
}
